{ open Parser }

let letter = ['a'-'z' 'A'-'Z']
let digit = ['0' - '9']
let character = ['`' '~' ' ' '!' '@' '#' '$' '%' '^' '&' '*' '(' ')' '-' '_' '=' '+' '[' '{' ']' '}' '|' ';' ':' ''' ',' '<' '.' '>' '/' '?']
let whitespace = ['\t' ' ' '\r' '\n']
let id = letter (letter | digit | '_' )* 
 (* Attention '\' are not included here. *)

rule token = parse
  whitespace { token lexbuf }
| "(:" { comment lexbuf }
| "v1" { V1 }
| "v2" { V2 }
| "v3" { V3 }
| "v4" { V4 }
| "int" { INT }
| "string" { CHARS }
| "line" { OBJLINE }
| "triangle" { OBJTRIANGLE }
| "ellipse" { OBJELLIPSE }
| "rectangle" { OBJRECTANGLE }
| "shape" { OBJSHAPE }
| "else" { ELSE }
| "while" { WHILE }
| "for" { FOR }
| "if" { IF }
| "return" { RETURN }
| id as lit { ID(lit)} 
| "S:{"whitespace*(digit)+whitespace+(digit+)whitespace+'"'(letter | digit | character )*'"'whitespace*'}' as lit { STRING(lit) }
| "R:{"whitespace*(digit)+whitespace+(digit)+whitespace+(digit)+whitespace+(digit)+whitespace*'}' as lit { RECTANGLE(lit) }
| "E:{"whitespace*(digit)+whitespace+(digit)+whitespace+(digit)+whitespace+(digit)+whitespace*'}' as lit { ELLIPSE(lit) }
| "L:{"whitespace*(digit)+whitespace+(digit)+whitespace+(digit)+whitespace+(digit)+whitespace*'}' as lit { LINE(lit) }
| '-'?(digit)+ as lit { LITERAL(int_of_string lit) }
| "R:" { RTOKEN }
| "E:" { ETOKEN }
| "L:" { LTOKEN }
| "==" { EQ }
| "!=" { NEQ }
| "<=" { LEQ }
| ">=" { GEQ }
| '>' { GT }
| '<' { LT }
| '!' { NOT }
| '(' { LPAREN }
| ')' { RPAREN }
| '{' { LBRACE }
| '}' { RBRACE }
| '[' { LBRACKET } 
| ']' { RBRACKET } 
| '.' { MEMBERIN }
| "=>" { SHIFT }
| "->" { MOVETO }
| ';' { SEMI }
| '=' { ASSIGN } 
| ',' { COMMA }
| '+' { PLUS }
| '-' { MINUS }
| '*' { TIMES }
| '/' { DIVIDE }
| eof { EOF }

and comment = 
	parse ":)" { token lexbuf }
	| _ {comment lexbuf}
